﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using Infragistics.Win.UltraWinCalcManager;
using Infragistics.Win.CalcEngine;
using System.Collections;
using System.IO;

namespace BYManageInfoSystem
{
    public partial class Frm_FeeDLYSTruePayTab : DockContent
    {
        private bool m_bClearing = false;
        private DGBY.BLL.FactoryDataTab m_bllFactoryDataTab = new DGBY.BLL.FactoryDataTab();
        private DGBY.BLL.TCCompDataTab m_bllTCCompDataTab = new DGBY.BLL.TCCompDataTab();
        private DGBY.BLL.T_ACL_User m_bllT_ACL_User = new DGBY.BLL.T_ACL_User();
        
        
        private DGBY.BLL.ZhuangGuiSiteTab m_bllZhuangGuiSiteTab = new DGBY.BLL.ZhuangGuiSiteTab();
        private DGBY.BLL.SJPackingTab m_bllSJPackingTab = new DGBY.BLL.SJPackingTab();
        private DGBY.BLL.PaidanRegisterTab m_bllPaidanRegisterTab = new DGBY.BLL.PaidanRegisterTab();
        Hashtable m_SQLStringList = new Hashtable();
        ArrayList m_arrayList = new ArrayList();
        private bool m_bIsPay = true;
  //      private DGBY.BLL.SJPackingTab m_bllSJPackingTab = new DGBY.BLL.SJPackingTab();
   //     private readonly DGBY.BLL.BGCKHTTab m_bllBGCKHTTab = new DGBY.BLL.BGCKHTTab();
        private DGBY.BLL.FeeDLYSTruePayTab m_bllFeeDLYSTruePayTab = new DGBY.BLL.FeeDLYSTruePayTab();
        private bool m_bInsertFlag = false;
        private int m_nDelIndex = -1;
        private int m_nFeeDLYSTruePayTabID = -1;
        private DGBY.Model.FeeDLYSTruePayTab m_modelFeeDLYSTruePayTab = new DGBY.Model.FeeDLYSTruePayTab();
        private DGBY.BLL.HxdNoTab m_bllHxdNoTab = new DGBY.BLL.HxdNoTab();
        private DGBY.BLL.BYDepartTab m_bllBYDepartTab = new DGBY.BLL.BYDepartTab();
     //   private DGBY.BLL.BGHDataTab m_bllBGHDataTab = new DGBY.BLL.BGHDataTab();
    //    private DGBY.BLL.BGHRecvPeoTelTab m_bllBGHRecvPeoTelTab = new DGBY.BLL.BGHRecvPeoTelTab();

        private DGBY.BLL.FeeSJRecvMoneyPersonTab m_bllFeeSJRecvMoneyPersonTab = new DGBY.BLL.FeeSJRecvMoneyPersonTab();
        private string m_strFolder = "d:\\运输费用表\\";

        //Hashtable m_SQLStringList = new Hashtable();
        //ArrayList m_arrayList = new ArrayList();
        private void InitComBox()
        {

            DataSet ds = m_bllFeeSJRecvMoneyPersonTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxRecvPerson.DataSource = ds.Tables[0];

                this.comboBoxRecvPerson.ValueMember = "FeeSJRecvMoneyPersonTabID";
                this.comboBoxRecvPerson.DisplayMember = "收款人";
                this.comboBoxRecvPerson.AutoCompleteSource = AutoCompleteSource.ListItems;
                this.comboBoxRecvPerson.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
                this.comboBoxRecvPerson.SelectedIndex = 0;
            }
            ds = m_bllFactoryDataTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxFac.DataSource = ds.Tables[0];

                this.comboBoxFac.ValueMember = "FactoryDataTabID";
                this.comboBoxFac.DisplayMember = "工厂简称";
                this.comboBoxFac.AutoCompleteSource = AutoCompleteSource.ListItems;
                this.comboBoxFac.AutoCompleteMode = AutoCompleteMode.SuggestAppend;

                this.comboBoxFac.SelectedIndex = 0;
            }
            ds = m_bllBYDepartTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxDept.DataSource = ds.Tables[0];
                this.comboBoxDept.DisplayMember = "部门名称";
                this.comboBoxDept.ValueMember = "BYDepartTabID";
                this.comboBoxDept.SelectedIndex = 6;
            }
        }
        private void InitColumnWidth()
        {
            ultraGrid1.DisplayLayout.Bands[0].Columns["工厂简称"].Width = 60;
            ultraGrid1.DisplayLayout.Bands[0].Columns["拖车行简称"].Width = 75;
            ultraGrid1.DisplayLayout.Bands[0].Columns["装柜镇区"].Width = 60;
            ultraGrid1.DisplayLayout.Bands[0].Columns["跟单人员"].Width = 60;
            /*
            ultraGrid1.DisplayLayout.Bands[0].Columns["对公编号"].Width = 130;
            ultraGrid1.DisplayLayout.Bands[0].Columns["对私编号"].Width = 130;
            ultraGrid1.DisplayLayout.Bands[0].Columns["实付日期"].Width = 95;
            ultraGrid1.DisplayLayout.Bands[0].Columns["录入日期"].Width = 95;
            */

            ultraGrid1.DisplayLayout.Bands[0].Columns["柜号"].Width = 90;
            ultraGrid1.DisplayLayout.Bands[0].Columns["申报日期"].Width = 95;
            ultraGrid1.DisplayLayout.Bands[0].Columns["应收费用计提年月"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["装柜日期"].Width = 95;
            ultraGrid1.DisplayLayout.Bands[0].Columns["合同编号"].Width = 75;
            ultraGrid1.DisplayLayout.Bands[0].Columns["运输费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["异提费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["打单费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["超重费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["押车费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["高速费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["过磅费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["拼柜费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["堆存费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["吊柜费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["封条费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["返空费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["改单费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["转关费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["其他费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["金额合计"].Width = 60;
            /*
            ultraGrid1.DisplayLayout.Bands[0].Columns["应收运输费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["应收异提费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["应收打单费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["应收超重费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["应收押车费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["应收高速费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["应收过磅费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["应收拼柜费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["应收堆存费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["应收吊柜费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["应收封条费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["应收返空费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["应收改单费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["应收转关费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["应收其他费"].Width = 50;
            ultraGrid1.DisplayLayout.Bands[0].Columns["应收金额合计"].Width = 60;
            */
            ultraGrid1.DisplayLayout.Bands[0].Columns["经办人"].Width = 60;
            //ultraGrid1.DisplayLayout.Bands[0].Columns["收款人"].Width = 60;
            ultraGrid1.DisplayLayout.Bands[0].Columns["备注"].Width = 100;
        }
        public Frm_FeeDLYSTruePayTab()
        {
            InitializeComponent();
        }
        public Frm_FeeDLYSTruePayTab(int nFeeDLYSTruePayTabID)
        {
            InitializeComponent();
            m_nFeeDLYSTruePayTabID = nFeeDLYSTruePayTabID;
            ShowAllRecord("FeeDLYSTruePayTabID = '" + nFeeDLYSTruePayTabID + "'", true);
        }
        public static void ultraGrid1_InitializeRowFilter(Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
            //ultraGrid1.DisplayLayout.Override.RowSizing = RowSizing.AutoFree;
            //foreach (UltraGridColumn ugc in ultraGrid1.DisplayLayout.Bands[0].Columns)
            //    ugc.PerformAutoResize();
            // FILTER ROW FUNCTIONALITY RELATED ULTRAGRID SETTINGS
            //e.Layout.Override.RowFilterAction = RowFilterAction.DisableFilteredOutRows;
            // ----------------------------------------------------------------------------------
            // Enable the the filter row user interface by setting the FilterUIType to FilterRow.
            e.Layout.Override.FilterUIType = FilterUIType.FilterRow;
            //e.Layout.Override.RowFilterMode = RowFilterMode.AllRowsInBand;
            // FilterEvaluationTrigger specifies when UltraGrid applies the filter criteria typed 
            // into a filter row. Default is OnCellValueChange which will cause the UltraGrid to
            // re-filter the data as soon as the user modifies the value of a filter cell.
            e.Layout.Override.FilterEvaluationTrigger = FilterEvaluationTrigger.OnCellValueChange;
            //e.Layout.Override.RowFilterMode = RowFilterMode.AllRowsInBand;
            // By default the UltraGrid selects the type of the filter operand editor based on
            // the column's DataType. For DateTime and boolean columns it uses the column's editors.
            // For other column types it uses the Combo. You can explicitly specify the operand
            // editor style by setting the FilterOperandStyle on the override or the individual
            // columns.

            e.Layout.Override.FilterOperandStyle = FilterOperandStyle.DropDownList;

            // By default UltraGrid displays user interface for selecting the filter operator. 
            // You can set the FilterOperatorLocation to hide this user interface. This
            // property is available on column as well so it can be controlled on a per column
            // basis. Default is WithOperand. This property is exposed off the column as well.
            e.Layout.Override.FilterOperatorLocation = FilterOperatorLocation.WithOperand;

            // By default the UltraGrid uses StartsWith as the filter operator. You use
            // the FilterOperatorDefaultValue property to specify a different filter operator
            // to use. This is the default or the initial filter operator value of the cells
            // in filter row. If filter operator user interface is enabled (FilterOperatorLocation
            // is not set to None) then that ui will be initialized to the value of this
            // property. The user can then change the operator as he/she chooses via the operator
            // drop down.
            e.Layout.Override.FilterOperatorDefaultValue = FilterOperatorDefaultValue.StartsWith;

            // FilterOperatorDropDownItems property can be used to control the options provided
            // to the user for selecting the filter operator. By default UltraGrid bases 
            // what operator options to provide on the column's data type. This property is
            // avaibale on the column as well.
            //e.Layout.Override.FilterOperatorDropDownItems = FilterOperatorDropDownItems.All;

            // By default UltraGrid displays a clear button in each cell of the filter row
            // as well as in the row selector of the filter row. When the user clicks this
            // button the associated filter criteria is cleared. You can use the 
            // FilterClearButtonLocation property to control if and where the filter clear
            // buttons are displayed.
            e.Layout.Override.FilterClearButtonLocation = FilterClearButtonLocation.RowAndCell;

            // Appearance of the filter row can be controlled using the FilterRowAppearance proeprty.
            e.Layout.Override.FilterRowAppearance.BackColor = Color.LightYellow;

            // You can use the FilterRowPrompt to display a prompt in the filter row. By default
            // UltraGrid does not display any prompt in the filter row.
            e.Layout.Override.FilterRowPrompt = "Click here to filter data...";

            // You can use the FilterRowPromptAppearance to change the appearance of the prompt.
            // By default the prompt is transparent and uses the same fore color as the filter row.
            // You can make it non-transparent by setting the appearance' BackColorAlpha property 
            // or by setting the BackColor to a desired value.
            e.Layout.Override.FilterRowPromptAppearance.BackColorAlpha = Alpha.Opaque;

            // By default the prompt is spread across multiple cells if it's bigger than the
            // first cell. You can confine the prompt to a particular cell by setting the
            // SpecialRowPromptField property off the band to the key of a column.
            //e.Layout.Bands[0].SpecialRowPromptField = e.Layout.Bands[0].Columns[0].Key;

            // Display a separator between the filter row other rows. SpecialRowSeparator property 
            // can be used to display separators between various 'special' rows, including for the
            // filter row. This property is a flagged enum property so it can take multiple values.
            e.Layout.Override.SpecialRowSeparator = SpecialRowSeparator.FilterRow;

            // You can control the appearance of the separator using the SpecialRowSeparatorAppearance
            // property.
            e.Layout.Override.SpecialRowSeparatorAppearance.BackColor = Color.FromArgb(233, 242, 199);

            //   UltraGridBand band = e.Layout.Bands[0];
            //   band.ColumnFilters["原币金额"].FilterConditions.Clear();
            //   band.ColumnFilters["原币金额"].FilterConditions.Add(

            //FilterComparisionOperator.GreaterThan, 5);
            //   band.ColumnFilters["原币金额"].FilterConditions.Add(

            //FilterComparisionOperator.LessThan, 10);
            //   band.ColumnFilters["原币金额"].LogicalOperator = FilterLogicalOperator.And;
        }
        private void ShowAllRecord(string strWhere, bool bIsPay)
        {

            DataSet dsTemp = m_bllFactoryDataTab.GetList("");

            this.ultraDropDownFac.DataSource = dsTemp.Tables[0];
            this.ultraDropDownFac.DisplayMember = "工厂简称";
            this.ultraDropDownFac.ValueMember = "FactoryDataTabID";
            this.ultraDropDownFac.DisplayLayout.Bands[0].Columns[0].Hidden = true;
            for (int i = 0; i < this.ultraDropDownFac.DisplayLayout.Bands[0].Columns.Count; i++)
                this.ultraDropDownFac.DisplayLayout.Bands[0].Columns[i].Hidden = true;
            this.ultraDropDownFac.DisplayLayout.Bands[0].Columns["工厂简称"].Hidden = false;

            dsTemp = m_bllTCCompDataTab.GetList("");

            this.ultraDropDownTuoCheComp.DataSource = dsTemp.Tables[0];
            this.ultraDropDownTuoCheComp.DisplayMember = "拖车公司简称";
            this.ultraDropDownTuoCheComp.ValueMember = "TCCompDataTabID";
            this.ultraDropDownTuoCheComp.DisplayLayout.Bands[0].Columns[0].Hidden = true;
            for (int i = 0; i < this.ultraDropDownTuoCheComp.DisplayLayout.Bands[0].Columns.Count; i++)
                this.ultraDropDownTuoCheComp.DisplayLayout.Bands[0].Columns[i].Hidden = true;
            this.ultraDropDownTuoCheComp.DisplayLayout.Bands[0].Columns["拖车公司简称"].Hidden = false;

            dsTemp = m_bllT_ACL_User.GetList("");

            this.ultraDropDownUser.DataSource = dsTemp.Tables[0];
            this.ultraDropDownUser.DisplayMember = "用户名称";
            this.ultraDropDownUser.ValueMember = "UserPasswordTabID";
            this.ultraDropDownUser.DisplayLayout.Bands[0].Columns[0].Hidden = true;
            for (int i = 0; i < this.ultraDropDownUser.DisplayLayout.Bands[0].Columns.Count; i++)
                this.ultraDropDownUser.DisplayLayout.Bands[0].Columns[i].Hidden = true;
            this.ultraDropDownUser.DisplayLayout.Bands[0].Columns["用户名称"].Hidden = false;

            m_bIsPay = bIsPay;
            DataSet ds = m_bllFeeDLYSTruePayTab.GetDLYSInfo(strWhere);
            ultraGrid1.DataSource = null;

            ultraGrid1.DataSource = ds.Tables[0];
            //this.ultraGrid1.DisplayLayout.Bands[0].Columns["集装箱柜号"].CellMultiLine = Infragistics.Win.DefaultableBoolean.True;

            ultraGrid1.DisplayLayout.Bands[0].Columns[0].Hidden = true;
            ultraGrid1.DisplayLayout.Bands[0].Columns[1].Hidden = true;
            if (m_bIsPay)
            {
                /*
                ultraGrid1.DisplayLayout.Bands[0].Columns["应收运输费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["应收异提费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["应收打单费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["应收超重费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["应收押车费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["应收高速费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["应收过磅费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["应收拼柜费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["应收堆存费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["应收吊柜费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["应收封条费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["应收返空费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["应收改单费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["应收转关费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["应收其他费"].Hidden = true;        
                ultraGrid1.DisplayLayout.Bands[0].Columns["应收金额合计"].Hidden = true;
                */
            }                                              
            else
            {
                ultraGrid1.DisplayLayout.Bands[0].Columns["运输费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["异提费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["打单费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["超重费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["押车费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["高速费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["过磅费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["拼柜费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["堆存费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["吊柜费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["封条费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["返空费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["改单费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["转关费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["其他费"].Hidden = true;
                ultraGrid1.DisplayLayout.Bands[0].Columns["金额合计"].Hidden = true;      
            }
            
            //ultraGrid1.DisplayLayout.Bands[0].Columns["是否已同步费用"].Hidden = true;
            //ultraGrid1.DisplayLayout.Bands[0].Columns["实付费用计提年月"].Hidden = true;
            this.ultraGrid1.DisplayLayout.Bands[0].Columns["工厂简称"].ValueList = this.ultraDropDownFac;
            this.ultraGrid1.DisplayLayout.Bands[0].Columns["拖车行简称"].ValueList = this.ultraDropDownTuoCheComp;
            this.ultraGrid1.DisplayLayout.Bands[0].Columns["跟单人员"].ValueList = this.ultraDropDownUser;

        }
        private void Frm_FeeDLYSTruePayTab_Load(object sender, EventArgs e)
        {
            ClassUltraGridCommonSet.InitUltraWinGridSetting(this.ultraGrid1);
            InitComBox();
        }

        private void buttonShowAll_Click(object sender, EventArgs e)
        {
            ShowAllRecord("", true);
        }

        private void buttonShowAllRecv_Click(object sender, EventArgs e)
        {
            //ShowAllRecord("", false);
        }

        private void ultraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e)
        {
            InitColumnWidth();
            if (this.checkBox1.Checked == true)
                ultraGrid1_InitializeRowFilter(e);
            else
                ClassUltraGridCommonSet.ultraGrid1_InitializeRowFilter(e);

            SummarySettings averageSummary =
e.Layout.Bands[0].Summaries.Add(
"金额合计",
SummaryType.Sum,
e.Layout.Bands[0].Columns["金额合计"]);
            averageSummary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
            averageSummary.SummaryPositionColumn = averageSummary.SourceColumn;
            averageSummary.DisplayFormat = "{0:.##}";
            averageSummary.Band.Override.SummaryFooterCaptionVisible = DefaultableBoolean.False;
            averageSummary.Band.Override.BorderStyleSummaryFooter = UIElementBorderStyle.None;
            averageSummary.SummaryDisplayArea = SummaryDisplayAreas.TopFixed;
/*
            averageSummary =
 e.Layout.Bands[0].Summaries.Add(
 "应收金额合计",
 SummaryType.Sum,
 e.Layout.Bands[0].Columns["应收金额合计"]);
            averageSummary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
            averageSummary.SummaryPositionColumn = averageSummary.SourceColumn;
            averageSummary.DisplayFormat = "{0:.##}";
            averageSummary.Band.Override.SummaryFooterCaptionVisible = DefaultableBoolean.False;
            averageSummary.Band.Override.BorderStyleSummaryFooter = UIElementBorderStyle.None;
            averageSummary.SummaryDisplayArea = SummaryDisplayAreas.TopFixed;*/

            foreach (UltraGridColumn column2 in ultraGrid1.DisplayLayout.Bands[0].Columns)
            {
                string str = column2.Header.Caption;
                if (str == "金额合计" 
                    || str == "装柜镇区" || str == "装柜日期"
                    || str == "申报日期" || str == "经办人" || str == "柜号")
                {
                    column2.CellAppearance.BackColor = Color.Coral;
                    column2.CellActivation = Activation.ActivateOnly;
                }
            }
        }

        private void ultraGrid1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter && e.Modifiers == Keys.Control)
            {

                if (!m_bInsertFlag)
                {
                    UltraGridRow row = this.ultraGrid1.DisplayLayout.Bands[0].AddNew();
                    //  row.Cells[2] = DateTime.Parse("1900-01-01");
                }
            }
            switch (e.KeyCode)
            {

                case Keys.Up:
                    {
                        UltraGridCell gridCell = this.ultraGrid1.ActiveCell;
                        if (null == gridCell)
                            return;     

                        string strTemp = this.ultraGrid1.ActiveCell.Column.Header.Caption;
                        //if (strTemp == "经营公司" | strTemp == "客户" | strTemp == "币种" | strTemp == "收款方式")
                        //    return;
                        int nColumnIndex = this.ultraGrid1.ActiveCell.Column.Index;
                        int nIndex = ultraGrid1.ActiveRow.Index;
                        if (nIndex > 0)
                            nIndex--;
                        this.ultraGrid1.PerformAction(UltraGridAction.ExitEditMode, false,
                          false);
                        this.ultraGrid1.PerformAction(UltraGridAction.AboveCell, false,
                          false);
                        e.Handled = true;
                        ultraGrid1.Rows[nIndex].Cells[nColumnIndex].IgnoreRowColActivation = true;
                        ultraGrid1.Rows[nIndex].Cells[nColumnIndex].Activation = Activation.AllowEdit;
                        ultraGrid1.Rows[nIndex].Cells[nColumnIndex].Activate();
                        this.ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false,
                          false);
                        break;
                    }

                case Keys.Down:
                    {
                        UltraGridCell gridCell = this.ultraGrid1.ActiveCell;
                        if (null == gridCell)
                            return;     

                        string strTemp = this.ultraGrid1.ActiveCell.Column.Header.Caption;
                        //if (strTemp == "经营公司" | strTemp == "客户" | strTemp == "币种" | strTemp == "收款方式")
                        //    return;
                        int nColumnIndex = this.ultraGrid1.ActiveCell.Column.Index;
                        int nIndex = ultraGrid1.ActiveRow.Index;
                        if (nIndex < ultraGrid1.Rows.Count - 1)
                            nIndex++;
                        this.ultraGrid1.PerformAction(UltraGridAction.ExitEditMode, false,
                          false);
                        this.ultraGrid1.PerformAction(UltraGridAction.BelowCell, false,
                          false);
                        e.Handled = true;
                        ultraGrid1.Rows[nIndex].Cells[nColumnIndex].IgnoreRowColActivation = true;
                        ultraGrid1.Rows[nIndex].Cells[nColumnIndex].Activation = Activation.AllowEdit;
                        ultraGrid1.Rows[nIndex].Cells[nColumnIndex].Activate();
                        this.ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false,
                          false);
                        break;
                    }

                case Keys.Right:
                    this.ultraGrid1.PerformAction(UltraGridAction.ExitEditMode, false,
                      false);
                    this.ultraGrid1.PerformAction(UltraGridAction.NextCellByTab, false,
                      false);
                    e.Handled = true;
                    this.ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false,
                      false);
                    break;
                case Keys.Left:
                    this.ultraGrid1.PerformAction(UltraGridAction.ExitEditMode, false,
                      false);
                    this.ultraGrid1.PerformAction(UltraGridAction.PrevCellByTab, false,
                      false);
                    e.Handled = true;
                    this.ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false,
                      false);
                    break;
            }
        }

        private void ResetRecord(int nFeeSJTruePayTabID)
        {

            try
            {
                DGBY.Model.FeeDLYSTruePayTab modelFeeDLYSTruePayTab
                    = m_bllFeeDLYSTruePayTab.GetModel(nFeeSJTruePayTabID);


                
                //modelFeeDLYSTruePayTab.PaidanRegisterTabID = Convert.ToInt32(ds.Tables[0].Rows[0]["PaidanRegisterTabID"].ToString(), 10);
                //modelFeeDLYSTruePayTab.FactoryDataTabID = Convert.ToInt32(ds.Tables[0].Rows[0]["FactoryDataTabID"].ToString(), 10);
                //modelFeeDLYSTruePayTab.TCCompDataTabID = Convert.ToInt32(CurrentUGR.Cells["TCCompDataTabID"].Value.ToString(), 10);
                //modelFeeDLYSTruePayTab.ZhuangGuiSiteTabID = Convert.ToInt32(CurrentUGR.Cells["TCCompDataTabID"].Value.ToString(), 10);
                //modelFeeDLYSTruePayTab.UserPasswordTabID = Convert.ToInt32(CurrentUGR.Cells["UserPasswordTabID2"].Value.ToString(), 10);


                modelFeeDLYSTruePayTab.YSFee = 0;
                modelFeeDLYSTruePayTab.YTFee = 0;
                modelFeeDLYSTruePayTab.DDFee = 0;
                modelFeeDLYSTruePayTab.CZFee = 0;
                modelFeeDLYSTruePayTab.YCFee = 0;
                modelFeeDLYSTruePayTab.GSFee = 0;

                modelFeeDLYSTruePayTab.GBFee = 0;
                modelFeeDLYSTruePayTab.PGFee = 0;
                modelFeeDLYSTruePayTab.DCFee = 0;
                modelFeeDLYSTruePayTab.DGFee = 0;
                modelFeeDLYSTruePayTab.FTFee = 0;
                modelFeeDLYSTruePayTab.FKFee = 0;
                modelFeeDLYSTruePayTab.GDFee = 0;
                modelFeeDLYSTruePayTab.ZGFee = 0;
                modelFeeDLYSTruePayTab.OtherFee = 0;


                modelFeeDLYSTruePayTab.YSYSFee = 0;
                modelFeeDLYSTruePayTab.YSYTFee = 0;
                modelFeeDLYSTruePayTab.YSDDFee = 0;
                modelFeeDLYSTruePayTab.YSCZFee = 0;
                modelFeeDLYSTruePayTab.YSYCFee = 0;
                modelFeeDLYSTruePayTab.YSGSFee = 0;

                modelFeeDLYSTruePayTab.YSGBFee = 0;
                modelFeeDLYSTruePayTab.YSPGFee = 0;
                modelFeeDLYSTruePayTab.YSDCFee = 0;
                modelFeeDLYSTruePayTab.YSDGFee = 0;
                modelFeeDLYSTruePayTab.YSFTFee = 0;
                modelFeeDLYSTruePayTab.YSFKFee = 0;
                modelFeeDLYSTruePayTab.YSGDFee = 0;
                modelFeeDLYSTruePayTab.YSZGFee = 0;
                modelFeeDLYSTruePayTab.YSOtherFee = 0;

                modelFeeDLYSTruePayTab.ToPubBianHao = "";
                modelFeeDLYSTruePayTab.ToPrivateBianHao = "";

                modelFeeDLYSTruePayTab.InputDate = null;
                modelFeeDLYSTruePayTab.TruePayDate = null;
                modelFeeDLYSTruePayTab.SBDate = DateTime.Parse("1900-01-01");

                modelFeeDLYSTruePayTab.TruePayMonth = 0;
                modelFeeDLYSTruePayTab.ShouldPayMonth = 0;
                modelFeeDLYSTruePayTab.PubTruePayMoney = 0;
                modelFeeDLYSTruePayTab.PrivateTruePayMoney = 0;
                //modelFeeDLYSTruePayTab.ZGDate = (DateTime)CurrentUGR.Cells["装柜日期"].Value;


                modelFeeDLYSTruePayTab.JinBanPerson = "";
                modelFeeDLYSTruePayTab.RecvMonyePerson = "";
                modelFeeDLYSTruePayTab.IsToRecvPayTab = 0;
                modelFeeDLYSTruePayTab.IsToFinCheckMoneyTab = 0;

                modelFeeDLYSTruePayTab.Note = "";

                modelFeeDLYSTruePayTab.bitFiledReserv1 = false;
                modelFeeDLYSTruePayTab.bitFiledReserv2 = false;

                modelFeeDLYSTruePayTab.stringFiledReserv1 = "";
                modelFeeDLYSTruePayTab.stringFiledReserv2 = "";
                modelFeeDLYSTruePayTab.stringFiledReserv3 = "";
                modelFeeDLYSTruePayTab.stringFiledReserv4 = "";

                modelFeeDLYSTruePayTab.intFiledReserv1 = 0;
                modelFeeDLYSTruePayTab.intFiledReserv2 = 0;
                modelFeeDLYSTruePayTab.intFiledReserv3 = 0;

                DateTime dtNow = System.DateTime.Now.Date;
                modelFeeDLYSTruePayTab.datetimeFiledReserv1 = dtNow;
                modelFeeDLYSTruePayTab.datetimeFiledReserv2 = dtNow;

                modelFeeDLYSTruePayTab.decimalFiledReserv1 = 0;
                modelFeeDLYSTruePayTab.decimalFiledReserv2 = 0;
                modelFeeDLYSTruePayTab.decimalFiledReserv3 = 0;
                modelFeeDLYSTruePayTab.decimalFiledReserv4 = 0;

                //modelFeeDLYSTruePayTab.ContractNo = ds.Tables[0].Rows[0]["合同编号"].ToString();

                m_bllFeeDLYSTruePayTab.Update(modelFeeDLYSTruePayTab);
                Frm_Main.Log2DB(this.Text, "清空", ultraGrid1.ActiveRow.Cells["合同编号"].Value.ToString());
             


            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }


        private void ResetUltraGridRow(int nRowIndex)
        {

            try
            {

                UltraGridRow CurrentUGR = ultraGrid1.Rows[nRowIndex];
                //CurrentUGR.Cells["PaidanRegisterTabID"].Value = -1;
                //CurrentUGR.Cells["工厂简称"].Value = 1;
                //CurrentUGR.Cells["拖车行简称"].Value = 1;
                //CurrentUGR.Cells["装柜镇区"].Value = 1;
                //CurrentUGR.Cells["跟单人员"].Value = 3;
                CurrentUGR.Cells["应收费用计提年月"].Value = 1;
                // CurrentUGR.Cells["实付费用计提年月"].Value = 1;

                //CurrentUGR.Cells["对公编号"].Value = "";
                //CurrentUGR.Cells["对私编号"].Value = "";
                CurrentUGR.Cells["合同编号"].Value = "";
                CurrentUGR.Cells["经办人"].Value = "";

                //CurrentUGR.Cells["收款人"].Value = "";
                CurrentUGR.Cells["备注"].Value = "";

                //CurrentUGR.Cells["实付日期"].Value = DBNull.Value;
                //CurrentUGR.Cells["录入日期"].Value = DBNull.Value;
                CurrentUGR.Cells["申报日期"].Value = DBNull.Value;
                CurrentUGR.Cells["装柜日期"].Value = DBNull.Value;

                if (m_bIsPay)
                {
                    CurrentUGR.Cells["运输费"].Value = 0;
                    CurrentUGR.Cells["异提费"].Value = 0;
                    CurrentUGR.Cells["打单费"].Value = 0;
                    CurrentUGR.Cells["超重费"].Value = 0;
                    CurrentUGR.Cells["押车费"].Value = 0;
                    CurrentUGR.Cells["高速费"].Value = 0;
                    CurrentUGR.Cells["过磅费"].Value = 0;
                    CurrentUGR.Cells["拼柜费"].Value = 0;
                    CurrentUGR.Cells["堆存费"].Value = 0;
                    CurrentUGR.Cells["吊柜费"].Value = 0;
                    CurrentUGR.Cells["封条费"].Value = 0;
                    CurrentUGR.Cells["返空费"].Value = 0;
                    CurrentUGR.Cells["改单费"].Value = 0;
                    CurrentUGR.Cells["转关费"].Value = 0;
                    CurrentUGR.Cells["其他费"].Value = 0;
                }
                else
                {
                    /*
                    CurrentUGR.Cells["应收运输费"].Value = 0;
                    CurrentUGR.Cells["应收异提费"].Value = 0;
                    CurrentUGR.Cells["应收打单费"].Value = 0;
                    CurrentUGR.Cells["应收超重费"].Value = 0;
                    CurrentUGR.Cells["应收押车费"].Value = 0;
                    CurrentUGR.Cells["应收高速费"].Value = 0;
                    CurrentUGR.Cells["应收过磅费"].Value = 0;
                    CurrentUGR.Cells["应收拼柜费"].Value = 0;
                    CurrentUGR.Cells["应收堆存费"].Value = 0;
                    CurrentUGR.Cells["应收吊柜费"].Value = 0;
                    CurrentUGR.Cells["应收封条费"].Value = 0;
                    CurrentUGR.Cells["应收返空费"].Value = 0;
                    CurrentUGR.Cells["应收改单费"].Value = 0;
                    CurrentUGR.Cells["应收转关费"].Value = 0;
                    CurrentUGR.Cells["应收其他费"].Value = 0;
                    */
                }


            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }

        private bool ModifyGoodsDetail(int nRowIndex)
        {
            try
            {
                if (m_bClearing)
                {
                    m_bClearing = false;
                    return false;
                }
                UltraGridRow CurrentUGR;
                CurrentUGR = ultraGrid1.Rows[nRowIndex];
                int nFeeDLYSTruePayTabID = Convert.ToInt32(CurrentUGR.Cells[0].Value.ToString(), 10);
                DGBY.Model.FeeDLYSTruePayTab modelFeeDLYSTruePayTab
                    = m_bllFeeDLYSTruePayTab.GetModel(nFeeDLYSTruePayTabID);


                modelFeeDLYSTruePayTab.ContractNo = CurrentUGR.Cells["合同编号"].Value.ToString();
               

                //if (CurrentUGR.Cells["实付日期"].Text != "")
                //{
                //    DateTime dtTemp = Convert.ToDateTime(CurrentUGR.Cells["实付日期"].Value.ToString());
                //    modelFeeDLYSTruePayTab.TruePayDate = dtTemp.Date;
                //}
                if (modelFeeDLYSTruePayTab.ToPrivateBianHao == "" && modelFeeDLYSTruePayTab.ToPubBianHao == "")
                    modelFeeDLYSTruePayTab.InputDate = System.DateTime.Now.Date;
                //modelFeeDLYSTruePayTab.TruePayMonth = Convert.ToInt32(CurrentUGR.Cells["实付费用计提年月"].Value.ToString(), 10);
                modelFeeDLYSTruePayTab.ShouldPayMonth = Convert.ToInt32(CurrentUGR.Cells["应收费用计提年月"].Value.ToString(), 10);
                string strBGH = CurrentUGR.Cells["工厂简称"].Value.ToString();
                if (ClassInputValid.IsNum(strBGH))
                {
                    modelFeeDLYSTruePayTab.FactoryDataTabID = Convert.ToInt32(CurrentUGR.Cells["工厂简称"].Value.ToString(), 10);
                }
                else
                {
                    DataSet ds = m_bllFactoryDataTab.GetList("FactoryNameJX = '" + strBGH + "'");
                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        modelFeeDLYSTruePayTab.FactoryDataTabID = Convert.ToInt32(ds.Tables[0].Rows[0]["FactoryDataTabID"].ToString(), 10);
                    }
                }
            
                strBGH = CurrentUGR.Cells["装柜镇区"].Value.ToString();
                if (ClassInputValid.IsNum(strBGH))
                {
                    modelFeeDLYSTruePayTab.ZhuangGuiSiteTabID = Convert.ToInt32(CurrentUGR.Cells["装柜镇区"].Value.ToString(), 10);
                }
                else
                {
                    DataSet ds = m_bllZhuangGuiSiteTab.GetList("ZhuangGuiSiteName = '" + strBGH + "'");
                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        modelFeeDLYSTruePayTab.ZhuangGuiSiteTabID = Convert.ToInt32(ds.Tables[0].Rows[0]["ZhuangGuiSiteTabID"].ToString(), 10);
                    }
                }

                

                strBGH = CurrentUGR.Cells["拖车行简称"].Value.ToString();
                if (ClassInputValid.IsNum(strBGH))
                {
                    modelFeeDLYSTruePayTab.TCCompDataTabID = Convert.ToInt32(CurrentUGR.Cells["拖车行简称"].Value.ToString(), 10);
                }
                else
                {
                    DataSet ds = m_bllTCCompDataTab.GetList("TCCompNameJX = '" + strBGH + "'");
                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        modelFeeDLYSTruePayTab.TCCompDataTabID = Convert.ToInt32(ds.Tables[0].Rows[0]["TCCompDataTabID"].ToString(), 10);
                    }
                }

                strBGH = CurrentUGR.Cells["跟单人员"].Value.ToString();
                if (ClassInputValid.IsNum(strBGH))
                {
                    modelFeeDLYSTruePayTab.UserPasswordTabID = Convert.ToInt32(CurrentUGR.Cells["跟单人员"].Value.ToString(), 10);
                }
                else
                {
                    DataSet ds = m_bllT_ACL_User.GetList("Name = '" + strBGH + "'");
                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        modelFeeDLYSTruePayTab.UserPasswordTabID = Convert.ToInt32(ds.Tables[0].Rows[0]["UserPasswordTabID"].ToString(), 10);
                    }
                }
                if (m_bIsPay)
                {
                    modelFeeDLYSTruePayTab.YSFee = Convert.ToDecimal(CurrentUGR.Cells["运输费"].Value.ToString());
                    modelFeeDLYSTruePayTab.YTFee = Convert.ToDecimal(CurrentUGR.Cells["异提费"].Value.ToString());
                    modelFeeDLYSTruePayTab.DDFee = Convert.ToDecimal(CurrentUGR.Cells["打单费"].Value.ToString());
                    modelFeeDLYSTruePayTab.CZFee = Convert.ToDecimal(CurrentUGR.Cells["超重费"].Value.ToString());

                    modelFeeDLYSTruePayTab.YCFee = Convert.ToDecimal(CurrentUGR.Cells["押车费"].Value.ToString());
                    modelFeeDLYSTruePayTab.GSFee = Convert.ToDecimal(CurrentUGR.Cells["高速费"].Value.ToString());
                    modelFeeDLYSTruePayTab.GBFee = Convert.ToDecimal(CurrentUGR.Cells["过磅费"].Value.ToString());
                    modelFeeDLYSTruePayTab.PGFee = Convert.ToDecimal(CurrentUGR.Cells["拼柜费"].Value.ToString());

                    modelFeeDLYSTruePayTab.DCFee = Convert.ToDecimal(CurrentUGR.Cells["堆存费"].Value.ToString());
                    modelFeeDLYSTruePayTab.DGFee = Convert.ToDecimal(CurrentUGR.Cells["吊柜费"].Value.ToString());
                    modelFeeDLYSTruePayTab.FTFee = Convert.ToDecimal(CurrentUGR.Cells["封条费"].Value.ToString());
                          
                    modelFeeDLYSTruePayTab.FKFee = Convert.ToDecimal(CurrentUGR.Cells["返空费"].Value.ToString());
                    modelFeeDLYSTruePayTab.GDFee = Convert.ToDecimal(CurrentUGR.Cells["改单费"].Value.ToString());
                    modelFeeDLYSTruePayTab.ZGFee = Convert.ToDecimal(CurrentUGR.Cells["转关费"].Value.ToString());
                    modelFeeDLYSTruePayTab.OtherFee = Convert.ToDecimal(CurrentUGR.Cells["其他费"].Value.ToString());

                   

                }
                else
                {
                    /*
                    modelFeeDLYSTruePayTab.YSYSFee = Convert.ToDecimal(CurrentUGR.Cells["应收运输费"].Value.ToString());
                    modelFeeDLYSTruePayTab.YSYTFee = Convert.ToDecimal(CurrentUGR.Cells["应收异提费"].Value.ToString());
                    modelFeeDLYSTruePayTab.YSDDFee = Convert.ToDecimal(CurrentUGR.Cells["应收打单费"].Value.ToString());
                    modelFeeDLYSTruePayTab.YSCZFee = Convert.ToDecimal(CurrentUGR.Cells["应收超重费"].Value.ToString());

                    modelFeeDLYSTruePayTab.YSYCFee = Convert.ToDecimal(CurrentUGR.Cells["应收押车费"].Value.ToString());
                    modelFeeDLYSTruePayTab.YSGSFee = Convert.ToDecimal(CurrentUGR.Cells["应收高速费"].Value.ToString());
                    modelFeeDLYSTruePayTab.YSGBFee = Convert.ToDecimal(CurrentUGR.Cells["应收过磅费"].Value.ToString());
                    modelFeeDLYSTruePayTab.YSPGFee = Convert.ToDecimal(CurrentUGR.Cells["应收拼柜费"].Value.ToString());

                    modelFeeDLYSTruePayTab.YSDCFee = Convert.ToDecimal(CurrentUGR.Cells["应收堆存费"].Value.ToString());
                    modelFeeDLYSTruePayTab.YSDGFee = Convert.ToDecimal(CurrentUGR.Cells["应收吊柜费"].Value.ToString());
                    modelFeeDLYSTruePayTab.YSFTFee = Convert.ToDecimal(CurrentUGR.Cells["应收封条费"].Value.ToString());
                    modelFeeDLYSTruePayTab.YSFKFee = Convert.ToDecimal(CurrentUGR.Cells["应收返空费"].Value.ToString());

                    modelFeeDLYSTruePayTab.YSGDFee = Convert.ToDecimal(CurrentUGR.Cells["应收改单费"].Value.ToString());
                    modelFeeDLYSTruePayTab.YSZGFee = Convert.ToDecimal(CurrentUGR.Cells["应收转关费"].Value.ToString());
                    modelFeeDLYSTruePayTab.YSOtherFee = Convert.ToDecimal(CurrentUGR.Cells["应收其他费"].Value.ToString());
                    */
                }         
                    
                //momodelFeeDLYSTruePayTab.DGFeedelFeeDLYSTruePayTab.isChaGui = Convert.ToBoolean(CurrentUGR.Cells["是否已核对金额"].Value.ToString());
                //momodelFeeDLYSTruePayTab.ZGFeedelFeeDLYSTruePayTab.isGaiChuan = Convert.ToBoolean(CurrentUGR.Cells["是否改船"].Value.ToString());
                //modelFeeDLYSTruePayTab.isSaoMiao = Convert.ToBoolean(CurrentUGR.Cells["是否扫描"].Value.ToString());

                modelFeeDLYSTruePayTab.JinBanPerson = modelFeeDLYSTruePayTab.JinBanPerson != ""
                    ? CurrentUGR.Cells["经办人"].Value.ToString()
                    : Frm_Main.m_strLoginUser;
                /*
                modelFeeDLYSTruePayTab.RecvMonyePerson = modelFeeDLYSTruePayTab.RecvMonyePerson != ""
                    ? CurrentUGR.Cells["收款人"].Value.ToString()
                    : this.comboBoxRecvPerson.Text;*/

                //modelFeeDLYSTruePayTab.IsToRecvPayTab = Convert.ToInt32(CurrentUGR.Cells["是否已提取至应收应付登记表"].Value.ToString(), 10);
                //modelFeeDLYSTruePayTab.IsToFinCheckMoneyTab = Convert.ToInt32(CurrentUGR.Cells["是否已提取至财务对帐"].Value.ToString(), 10);
                modelFeeDLYSTruePayTab.Note = CurrentUGR.Cells["备注"].Value.ToString();


                //if (modelFeeDLYSTruePayTab.ToPubFormula != "")
                //    modelFeeDLYSTruePayTab.PubTruePayMoney
                //        = this.ultraCalcManager1.Calculate(modelFeeDLYSTruePayTab.ToPubFormula).ToDecimal();
                //if (modelFeeDLYSTruePayTab.ToPrivateFormula != "")
                //    modelFeeDLYSTruePayTab.PrivateTruePayMoney
                //        = this.ultraCalcManager1.Calculate(modelFeeDLYSTruePayTab.ToPrivateFormula).ToDecimal();

                //modelFeeDLYSTruePayTab.PubTruePayMoney = (Decimal)CurrentUGR.Cells["对公实付金额"].Value;
                //modelFeeDLYSTruePayTab.PrivateTruePayMoney = (Decimal)CurrentUGR.Cells["对私实付金额"].Value;
                //modelFeeDLYSTruePayTab.PubTruePayMoney = (Decimal)CurrentUGR.Cells["应付实付金额"].Value;

                //CurrentUGR.Cells["对公实付金额"].Value = modelFeeDLYSTruePayTab.PubTruePayMoney;
                //CurrentUGR.Cells["对私实付金额"].Value = modelFeeDLYSTruePayTab.PrivateTruePayMoney;
                //CurrentUGR.Cells["应付实付金额"].Value = modelFeeDLYSTruePayTab.PubTruePayMoney
                //    + modelFeeDLYSTruePayTab.PrivateTruePayMoney;
                //CurrentUGR.Cells["对私收款人"].Value = modelFeeDLYSTruePayTab.RecvMonyePerson;
                //CurrentUGR.Cells["经办人"].Value = modelFeeDLYSTruePayTab.JinBanPerson;
                //CurrentUGR.Cells["录入日期"].Value = modelFeeDLYSTruePayTab.InputDate;

                //if (m_bIsPay)
                //{
                //    CurrentUGR.Cells["通关单费"].Value = modelFeeDLYSTruePayTab.TGDFee;
                //    CurrentUGR.Cells["报关费"].Value = modelFeeDLYSTruePayTab.BGFee;
                //    CurrentUGR.Cells["港口建设费"].Value = modelFeeDLYSTruePayTab.GKJSFee;
                //    CurrentUGR.Cells["GPS费"].Value = modelFeeDLYSTruePayTab.KAFee;
                //    CurrentUGR.Cells["连柜费"].Value = modelFeeDLYSTruePayTab.LGFee;
                //    CurrentUGR.Cells["加页费"].Value = modelFeeDLYSTruePayTab.JYFee;
                //    CurrentUGR.Cells["查柜费"].Value = modelFeeDLYSTruePayTab.CGFee;
                //    CurrentUGR.Cells["改船费"].Value = modelFeeDLYSTruePayTab.GCFee;
                //    CurrentUGR.Cells["扫描费"].Value = modelFeeDLYSTruePayTab.SMFee;
                //    CurrentUGR.Cells["茶水费"].Value = modelFeeDLYSTruePayTab.CSFee;
                //    CurrentUGR.Cells["其他费用"].Value = modelFeeDLYSTruePayTab.OtherFee;
                //}
                //else
                //{
                //    CurrentUGR.Cells["应收通关单费"].Value = modelFeeDLYSTruePayTab.BGTGDFee;
                //    CurrentUGR.Cells["应收报关费"].Value = modelFeeDLYSTruePayTab.BGBGFee;
                //    CurrentUGR.Cells["应收港口建设费"].Value = modelFeeDLYSTruePayTab.BGGKJSFee;
                //    CurrentUGR.Cells["应收GPS费"].Value = modelFeeDLYSTruePayTab.BGKAFee;
                //    CurrentUGR.Cells["应收连柜费"].Value = modelFeeDLYSTruePayTab.BGLGFee;
                //    CurrentUGR.Cells["应收加页费"].Value = modelFeeDLYSTruePayTab.BGJYFee;
                //    CurrentUGR.Cells["应收查柜费"].Value = modelFeeDLYSTruePayTab.BGCGFee;
                //    CurrentUGR.Cells["应收改船费"].Value = modelFeeDLYSTruePayTab.BGGCFee;
                //    CurrentUGR.Cells["应收扫描费"].Value = modelFeeDLYSTruePayTab.BGSMFee;
                //    CurrentUGR.Cells["应收茶水费"].Value = modelFeeDLYSTruePayTab.BGCSFee;
                //    CurrentUGR.Cells["应收其他费用"].Value = modelFeeDLYSTruePayTab.BGOtherFee;
                //}


                m_bllFeeDLYSTruePayTab.Update(modelFeeDLYSTruePayTab);
                Frm_Main.Log2DB(this.Text, "修改", ultraGrid1.ActiveRow.Cells["合同编号"].Value.ToString());
                return true;

            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return false;
            }
        }
        private void ultraGrid1_BeforeRowUpdate(object sender, CancelableRowEventArgs e)
        {
            try
            {
                UltraGridRow CurrentUGR;
                CurrentUGR = ultraGrid1.Rows[e.Row.Index];

                if (m_bInsertFlag)
                {
                    ultraGrid1.Rows[e.Row.Index].Cells[2].Activation = Activation.ActivateOnly;
                    m_bInsertFlag = false;

                }
                else//修改
                {

                    ModifyGoodsDetail(e.Row.Index);

                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

        }

        private void 复制增加ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!m_bInsertFlag)
            {
                UltraGridRow row = this.ultraGrid1.DisplayLayout.Bands[0].AddNew();
                //  row.Cells[2] = DateTime.Parse("1900-01-01");
            }
        }
          



        private void InitNewAddRowValue(int nIndex)
        {
            UltraGridRow CurrentUGR = ultraGrid1.Rows[nIndex];
            CurrentUGR.Cells["PaidanRegisterTabID"].Value = -1;
            CurrentUGR.Cells["工厂简称"].Value = 1;
            CurrentUGR.Cells["拖车行简称"].Value = 1;
            CurrentUGR.Cells["装柜镇区"].Value = 1;
            CurrentUGR.Cells["跟单人员"].Value = 3;
            CurrentUGR.Cells["应收费用计提年月"].Value = 1;
           // CurrentUGR.Cells["实付费用计提年月"].Value = 1;

            //CurrentUGR.Cells["对公编号"].Value = "";
            //CurrentUGR.Cells["对私编号"].Value =  "";
            CurrentUGR.Cells["合同编号"].Value =  "";
            CurrentUGR.Cells["经办人"].Value =  "";
                  
            //CurrentUGR.Cells["收款人"].Value =  "";
            CurrentUGR.Cells["备注"].Value =  "";

            //CurrentUGR.Cells["实付日期"].Value = DateTime.Parse("1900-01-01");
            //CurrentUGR.Cells["录入日期"].Value = DateTime.Parse("1900-01-01");
            CurrentUGR.Cells["申报日期"].Value = DateTime.Parse("1900-01-01");
            CurrentUGR.Cells["装柜日期"].Value = DateTime.Parse("1900-01-01");

            if (m_bIsPay)
            {
                CurrentUGR.Cells["运输费"].Value = 0;
                CurrentUGR.Cells["异提费"].Value = 0;
                CurrentUGR.Cells["打单费"].Value = 0;
                CurrentUGR.Cells["超重费"].Value = 0;
                CurrentUGR.Cells["押车费"].Value = 0;
                CurrentUGR.Cells["高速费"].Value = 0;
                CurrentUGR.Cells["过磅费"].Value = 0;
                CurrentUGR.Cells["拼柜费"].Value = 0;
                CurrentUGR.Cells["堆存费"].Value = 0;
                CurrentUGR.Cells["吊柜费"].Value = 0;
                CurrentUGR.Cells["封条费"].Value = 0;
                CurrentUGR.Cells["返空费"].Value = 0;
                CurrentUGR.Cells["改单费"].Value = 0;
                CurrentUGR.Cells["转关费"].Value = 0;
                CurrentUGR.Cells["其他费"].Value = 0;
            }
            else
            {
                /*
                CurrentUGR.Cells["应收运输费"].Value = 0;
                CurrentUGR.Cells["应收异提费"].Value = 0;
                CurrentUGR.Cells["应收打单费"].Value = 0;
                CurrentUGR.Cells["应收超重费"].Value = 0;
                CurrentUGR.Cells["应收押车费"].Value = 0;
                CurrentUGR.Cells["应收高速费"].Value = 0;
                CurrentUGR.Cells["应收过磅费"].Value = 0;
                CurrentUGR.Cells["应收拼柜费"].Value = 0;
                CurrentUGR.Cells["应收堆存费"].Value = 0;
                CurrentUGR.Cells["应收吊柜费"].Value = 0;
                CurrentUGR.Cells["应收封条费"].Value = 0;
                CurrentUGR.Cells["应收返空费"].Value = 0;
                CurrentUGR.Cells["应收改单费"].Value = 0;
                CurrentUGR.Cells["应收转关费"].Value = 0;
                CurrentUGR.Cells["应收其他费"].Value = 0;
                */
            }

            if (m_bInsertFlag)
            {
                ultraGrid1.Rows[nIndex].Cells[2].Activation = Activation.ActivateOnly;
                m_bInsertFlag = false;
                AddGoodsDetail(nIndex);

            }
        }
        private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
        {
            ultraGrid1.Rows[e.Row.Index].Cells[1].IgnoreRowColActivation = true;
            ultraGrid1.Rows[e.Row.Index].Cells[1].Activation = Activation.AllowEdit;
            ultraGrid1.Rows[e.Row.Index].Cells[1].Activate();
            ultraGrid1.PerformAction(UltraGridAction.EnterEditMode);
            m_bInsertFlag = true;
            InitNewAddRowValue(e.Row.Index);
        }

        private bool AddGoodsDetail(int nRowIndex)
        {

            try
            {
                UltraGridRow CurrentUGR;
                CurrentUGR = ultraGrid1.Rows[nRowIndex];

                DGBY.Model.FeeDLYSTruePayTab modelFeeDLYSTruePayTab = new DGBY.Model.FeeDLYSTruePayTab();
                modelFeeDLYSTruePayTab.PaidanRegisterTabID = (int)CurrentUGR.Cells["PaidanRegisterTabID"].Value;
                modelFeeDLYSTruePayTab.FactoryDataTabID = 1;
                modelFeeDLYSTruePayTab.TCCompDataTabID = 1;
                modelFeeDLYSTruePayTab.ZhuangGuiSiteTabID = 1;
                modelFeeDLYSTruePayTab.UserPasswordTabID = 3;
         

                modelFeeDLYSTruePayTab.YSFee = 0;
                modelFeeDLYSTruePayTab.YTFee = 0;
                modelFeeDLYSTruePayTab.DDFee = 0;
                modelFeeDLYSTruePayTab.CZFee = 0;
                modelFeeDLYSTruePayTab.YCFee = 0;
                modelFeeDLYSTruePayTab.GSFee = 0;

                modelFeeDLYSTruePayTab.GBFee = 0;
                modelFeeDLYSTruePayTab.PGFee = 0;
                modelFeeDLYSTruePayTab.DCFee = 0;
                modelFeeDLYSTruePayTab.DGFee = 0;
                modelFeeDLYSTruePayTab.FTFee = 0;
                modelFeeDLYSTruePayTab.FKFee = 0;
                modelFeeDLYSTruePayTab.GDFee = 0;
                modelFeeDLYSTruePayTab.ZGFee = 0;
                modelFeeDLYSTruePayTab.OtherFee = 0;


                modelFeeDLYSTruePayTab.YSYSFee = 0;
                modelFeeDLYSTruePayTab.YSYTFee = 0;
                modelFeeDLYSTruePayTab.YSDDFee = 0;
                modelFeeDLYSTruePayTab.YSCZFee = 0;
                modelFeeDLYSTruePayTab.YSYCFee = 0;
                modelFeeDLYSTruePayTab.YSGSFee = 0;

                modelFeeDLYSTruePayTab.YSGBFee = 0;
                modelFeeDLYSTruePayTab.YSPGFee = 0;
                modelFeeDLYSTruePayTab.YSDCFee = 0;
                modelFeeDLYSTruePayTab.YSDGFee = 0;
                modelFeeDLYSTruePayTab.YSFTFee = 0;
                modelFeeDLYSTruePayTab.YSFKFee = 0;
                modelFeeDLYSTruePayTab.YSGDFee = 0;
                modelFeeDLYSTruePayTab.YSZGFee = 0;
                modelFeeDLYSTruePayTab.YSOtherFee = 0;

                modelFeeDLYSTruePayTab.ToPubBianHao = "";
                modelFeeDLYSTruePayTab.ToPrivateBianHao = "";

               
                modelFeeDLYSTruePayTab.SBDate = DateTime.Parse("1900-01-01");

                modelFeeDLYSTruePayTab.TruePayMonth = 0;
                modelFeeDLYSTruePayTab.ShouldPayMonth = 0;
                modelFeeDLYSTruePayTab.PubTruePayMoney = 0;
                modelFeeDLYSTruePayTab.PrivateTruePayMoney = 0;
                modelFeeDLYSTruePayTab.ZGDate = DateTime.Parse("1900-01-01");


               
                
                
                modelFeeDLYSTruePayTab.JinBanPerson = "";
                modelFeeDLYSTruePayTab.RecvMonyePerson = "";
                modelFeeDLYSTruePayTab.IsToRecvPayTab = 0;
                modelFeeDLYSTruePayTab.IsToFinCheckMoneyTab = 0;

                
                
                modelFeeDLYSTruePayTab.Note = "";

                modelFeeDLYSTruePayTab.bitFiledReserv1 = false;
                modelFeeDLYSTruePayTab.bitFiledReserv2 = false;

                modelFeeDLYSTruePayTab.stringFiledReserv1 = "";
                modelFeeDLYSTruePayTab.stringFiledReserv2 = "";
                modelFeeDLYSTruePayTab.stringFiledReserv3 = "";
                modelFeeDLYSTruePayTab.stringFiledReserv4 = "";

                modelFeeDLYSTruePayTab.intFiledReserv1 = 0;
                modelFeeDLYSTruePayTab.intFiledReserv2 = 0;
                modelFeeDLYSTruePayTab.intFiledReserv3 = 0;

                DateTime dtNow = System.DateTime.Now.Date;
                modelFeeDLYSTruePayTab.datetimeFiledReserv1 = dtNow;
                modelFeeDLYSTruePayTab.datetimeFiledReserv2 = dtNow;

                modelFeeDLYSTruePayTab.decimalFiledReserv1 = 0;
                modelFeeDLYSTruePayTab.decimalFiledReserv2 = 0;
                modelFeeDLYSTruePayTab.decimalFiledReserv3 = 0;
                modelFeeDLYSTruePayTab.decimalFiledReserv4 = 0;
                int nID = m_bllFeeDLYSTruePayTab.Add(modelFeeDLYSTruePayTab);

                DGBY.Model.PaidanRegisterTab modelPaidanRegisterTab = m_bllPaidanRegisterTab.GetModel(modelFeeDLYSTruePayTab.PaidanRegisterTabID);
                if (null == modelPaidanRegisterTab)
                    Frm_Main.Log2DB(this.Text, "增加", nID.ToString());
                else
                    Frm_Main.Log2DB(this.Text, "增加", ultraGrid1.ActiveRow.Cells["合同编号"].Value.ToString());


                //if (modelFeeDLYSTruePayTab.ArriveFacHour == 0)
                //    CurrentUGR.Cells["到厂小时"].Value = null;
                //if (modelFeeDLYSTruePayTab.ArriveFacMin == 0)
                //    CurrentUGR.Cells["到厂分钟"].Value = null;
                //if (modelFeeDLYSTruePayTab.GuoBangWeight == 0)
                //    CurrentUGR.Cells["过磅重量"].Value = null;
                //if (modelFeeDLYSTruePayTab.ZGHourCount == 0)
                //    CurrentUGR.Cells["装柜时长"].Value = null;

                ShowAllRecord("FeeDLYSTruePayTabID = '" + nID + "'", true);
                ultraGrid1.DisplayLayout.Bands[0].CardView = true;
                ultraGrid1.DisplayLayout.Bands[0].CardSettings.AllowLabelSizing = true;
                ultraGrid1.DisplayLayout.Bands[0].CardSettings.AllowSizing = true;
                ultraGrid1.DisplayLayout.Bands[0].CardSettings.Style = Infragistics.Win.UltraWinGrid.CardStyle.MergedLabels;
                ultraGrid1.DisplayLayout.Bands[0].CardSettings.ShowCaption = true;
                ultraGrid1.DisplayLayout.Bands[0].CardSettings.Width = 200;
           

                return true;

            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return false;
            }
        }

        private void ultraGrid1_AfterCellActivate(object sender, EventArgs e)
        {
            int iIndex = this.ultraGrid1.ActiveCell.Row.Index;
            if (iIndex < 0)
                return;
            m_nDelIndex = ultraGrid1.ActiveRow.Index;
        }

        private void 删除本行ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("确实要删除该记录么!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (dr == DialogResult.Cancel)
            {
                return;
            }
            int nIndex = m_nDelIndex;
            if (m_nDelIndex >= 0)
            {
                if (ultraGrid1.ActiveRow != null)
                {
                    UltraGridRow CurrentUGR = ultraGrid1.Rows[nIndex];
                    ultraGrid1.ActiveRow.Delete(false);
                }
            }
            else
            {
                MessageBox.Show("请选中要删除的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void ultraGrid1_BeforeRowsDeleted(object sender, BeforeRowsDeletedEventArgs e)
        {
            e.DisplayPromptMsg = false;
            if (!m_bInsertFlag)
            {
                int nSelectFeeDLYSTruePayTabID = Convert.ToInt32(ultraGrid1.ActiveRow.Cells[0].Value.ToString(), 10);
                DGBY.Model.FeeDLYSTruePayTab modelFeeDLYSTruePayTabOld
                    = m_bllFeeDLYSTruePayTab.GetModel(nSelectFeeDLYSTruePayTabID);

                if (modelFeeDLYSTruePayTabOld == null)
                {
                    MessageBox.Show("数据库不存在该记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (MessageBox.Show("确实要删除该条记录!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
                {
                    try
                    {

                        m_bllFeeDLYSTruePayTab.Delete(nSelectFeeDLYSTruePayTabID);
                        Frm_Main.Log2DB(this.Text, "删除", ultraGrid1.ActiveRow.Cells["合同编号"].Value.ToString());


                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        e.Cancel = true;
                    }
                }
                else
                {
                    e.Cancel = true;
                }
            }
            else
            {
                MessageBox.Show("插入未完成，不能删除记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                e.Cancel = true;
            }
        }

        private void buttonExportExcel_Click(object sender, EventArgs e)
        {
            DataTable dt = (DataTable)ultraGrid1.DataSource;

            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    SaveFileDialog sfd = new SaveFileDialog();
                    sfd.Filter = "Excel文件(*.xls)|*.xls";
                    string outFile = "";

                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        outFile = sfd.FileName;
                    }
                    else
                    {
                        return;
                    }

                    ultraGridExcelExporter1.Export(ultraGrid1, outFile);
                }
            }
        }

        private void ultraGrid1_AfterCellUpdate(object sender, CellEventArgs e)
        {
            int nIndex = e.Cell.Row.Index;
            if (nIndex < 0)
                return;
            if (e.Cell.Column.Key == "工厂简称")
            {

                UltraGridRow CurrentUGR = ultraGrid1.Rows[nIndex];
                string strID = e.Cell.Value.ToString();
                DataSet ds = m_bllFactoryDataTab.GetList("FactoryDataTab.FactoryDataTabid = '" + strID + "'");
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {

                    CurrentUGR.Cells["装柜镇区"].Value = ds.Tables[0].Rows[0]["所属镇区"].ToString();
           

                }
            }
        }

        private void buttonModYearMon_Click(object sender, EventArgs e)
        {
            if (!ClassInputValid.IsNum(textBoxYearMonth.Text))
            {
                errorProvider1.SetError(textBoxYearMonth, "必须输入数字");
                return;
            }
            int nYearMon = Convert.ToInt32(textBoxYearMonth.Text, 10);
            if (nYearMon < 201001 || nYearMon > 219912)
            {
                errorProvider1.SetError(textBoxYearMonth, "必须正确的年月，形如201206");
                return;
            }

            m_SQLStringList.Clear();
            m_arrayList.Clear();

            try
            {
                Infragistics.Win.UltraWinGrid.UltraGridRow[] ugr = ultraGrid1.Rows.GetFilteredInNonGroupByRows();

                DialogResult dr = MessageBox.Show("确实要批量修改以下" + ugr.Length.ToString() + "条记录的应收费用计提年月么", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (dr == DialogResult.Cancel)
                    return;


                for (int i = 0; i < ugr.Length; i++)
                {

                    int nID = Convert.ToInt32(ugr[i].Cells[0].Value.ToString(), 10);
                    DGBY.Model.FeeDLYSTruePayTab modelFeeDLYSTruePayTabOld
                                        = m_bllFeeDLYSTruePayTab.GetModel(nID);
                    modelFeeDLYSTruePayTabOld.ShouldPayMonth = nYearMon;
                    UltraGridRow CurrentUGR = ultraGrid1.Rows[ugr[i].Index];

                    m_bllFeeDLYSTruePayTab.TransUpdate(modelFeeDLYSTruePayTabOld
                        , m_SQLStringList, m_arrayList, i);

                    CurrentUGR.Cells["应收费用计提年月"].Value = nYearMon.ToString();
                }

                m_bllSJPackingTab.ExecuteSqlTran(m_SQLStringList, m_arrayList);
                Frm_Main.Log2DB(this.Text, "批量修改计提年月", nYearMon.ToString());
                MessageBox.Show("批量修改应收费用计提年月完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }

        private void buttonBatchModifyDate_Click(object sender, EventArgs e)
        {

        }

        private void buttonSetEmpty_Click(object sender, EventArgs e)
        {

        }

        private void 清空该条记录ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("确实要清空该记录么!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (dr == DialogResult.Cancel)
            {
                return;
            }
            int nIndex = m_nDelIndex;
            if (m_nDelIndex >= 0)
            {
                ResetUltraGridRow(nIndex);
                UltraGridRow CurrentUGR;
                CurrentUGR = ultraGrid1.Rows[nIndex];
                int nFeeSJTruePayTabID = Convert.ToInt32(CurrentUGR.Cells[0].Value.ToString(), 10);
                ResetRecord(nFeeSJTruePayTabID);
                m_bClearing = true;
            }
            else
            {
                MessageBox.Show("请选中要清空的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            m_SQLStringList.Clear();
            m_arrayList.Clear();

            try
            {
                Infragistics.Win.UltraWinGrid.UltraGridRow[] ugr = ultraGrid1.Rows.GetFilteredInNonGroupByRows();

                DialogResult dr = MessageBox.Show("确实要批量置空以下" + ugr.Length.ToString() + "条记录的应收费用计提年月么", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (dr == DialogResult.Cancel)
                    return;


                for (int i = 0; i < ugr.Length; i++)
                {

                    int nID = Convert.ToInt32(ugr[i].Cells[0].Value.ToString(), 10);
                    DGBY.Model.FeeDLYSTruePayTab modelFeeDLYSTruePayTabOld
                                        = m_bllFeeDLYSTruePayTab.GetModel(nID);
                    modelFeeDLYSTruePayTabOld.ShouldPayMonth = 0;
                    UltraGridRow CurrentUGR = ultraGrid1.Rows[ugr[i].Index];

                    m_bllFeeDLYSTruePayTab.TransUpdate(modelFeeDLYSTruePayTabOld
                        , m_SQLStringList, m_arrayList, i);

                    CurrentUGR.Cells["应收费用计提年月"].Value = "0";
                }

                m_bllSJPackingTab.ExecuteSqlTran(m_SQLStringList, m_arrayList);
                Frm_Main.Log2DB(this.Text, "批量置空计提年月", "");
                MessageBox.Show("批量修改应收费用计提年月完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }

        private void 编辑本行ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int nIndex = m_nDelIndex;
            if (nIndex < 0)
                return;
            UltraGridRow CurrentUGR = ultraGrid1.Rows[nIndex];
            int nFeeDLYSTruePayTabID = (int)CurrentUGR.Cells["FeeDLYSTruePayTabID"].Value;
            ShowAllRecord("FeeDLYSTruePayTabID = '" + nFeeDLYSTruePayTabID + "'", true);
            ultraGrid1.DisplayLayout.Bands[0].CardView = true;
            ultraGrid1.DisplayLayout.Bands[0].CardSettings.AllowLabelSizing = true;
            ultraGrid1.DisplayLayout.Bands[0].CardSettings.AllowSizing = true;
            ultraGrid1.DisplayLayout.Bands[0].CardSettings.Style = Infragistics.Win.UltraWinGrid.CardStyle.MergedLabels;
            ultraGrid1.DisplayLayout.Bands[0].CardSettings.ShowCaption = true;
            ultraGrid1.DisplayLayout.Bands[0].CardSettings.Width = 200;
        }

        private void buttonFacSheet_Click(object sender, EventArgs e)
        {       
            ShowAllRecord("FactoryDataTab.FactoryDataTabID = '" + this.comboBoxFac.SelectedValue + "'", true);

            DataTable dt = (DataTable)ultraGrid1.DataSource;

            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    string strNow = DateTime.Now.Date.ToShortDateString();

                    string outFile = m_strFolder + strNow + @"\";
                    if (!Directory.Exists(outFile))//判断是否存在
                    {
                        Directory.CreateDirectory(outFile);//创建新路径
                    }

                    outFile = m_strFolder + strNow + @"\" +this.comboBoxFac.Text + ".xls";
                    ultraGridExcelExporter1.Export(ultraGrid1, outFile);

                    MessageBox.Show("运输费用表导出工厂" + this.comboBoxFac.Text + "信息完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }

        private void buttonDepSheet_Click(object sender, EventArgs e)
        {
            ShowAllRecord("BYCompanyTab.BYCompanyTabID = '" + this.comboBoxDept.SelectedValue + "'", true);

            DataTable dt = (DataTable)ultraGrid1.DataSource;

            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    string strNow = DateTime.Now.Date.ToShortDateString();

                    string outFile = m_strFolder + strNow + @"\";
                    if (!Directory.Exists(outFile))//判断是否存在
                    {
                        Directory.CreateDirectory(outFile);//创建新路径
                    }

                    outFile = m_strFolder + strNow + @"\" + this.comboBoxDept.Text + ".xls";
                    ultraGridExcelExporter1.Export(ultraGrid1, outFile);

                    MessageBox.Show("运输费用表导出部门" + this.comboBoxDept.Text + "信息完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
    }
}
